package gamesys;
import java.awt.Graphics2D;
import java.awt.event.KeyEvent;
import pkg.*;

@SuppressWarnings("serial")
public class NormalGame extends BaseGame {
	
	protected Map map;
	protected Player player;
	
	protected void intitialize(){
		
		map = new Map();
		map.createMap(10, 10);
		
		components.addComponent(map);
		setupBasics();
		
		components.initialize();
		populateMap();
	}
	
	protected void populateMap()
	{	
		Player play = (Player)manager.createEntity("player");
		play.setPosition(150,60);
		play = (Player)manager.createEntity("player");
		play.setPosition(100,300);
		play = (Player)manager.createEntity("player");
		play.setPosition(160,150);

	}
	
	protected void render(Graphics2D g)
	{
		super.render(g);
	}
	
	@Override
	public void keyPressed(KeyEvent e) 
	{
		super.keyPressed(e);
		Player.Direction dir = Player.Direction.Right;
		switch(e.getKeyCode())
		{
			case KeyEvent.VK_A: dir = Player.Direction.Left;break;
			case KeyEvent.VK_W: dir = Player.Direction.Up; break;
			case KeyEvent.VK_D: dir = Player.Direction.Right; break;
			case KeyEvent.VK_S: dir = Player.Direction.Down; break;
		}
		if(dir != player.getDirection())
		player.move(dir);
	}

	@Override
	public void keyReleased(KeyEvent e) 
	{
		super.keyReleased(e);
		switch(e.getKeyCode())
		{
			case KeyEvent.VK_A: 
			case KeyEvent.VK_W:
			case KeyEvent.VK_D:
			case KeyEvent.VK_S:
				player.stop();
			break;
		}
	}
}
